- topic 1
- topic 2
- topic 3
5/21/2019
In fact, up until recently, the Statistical Atlas had been published and released for each Census since 1870! A large compilation of data visualizaitons based on census data:
All of the tidyverse packages operate easily when you have data in this structure!
Three interrelated rules:
R is a vectorized language, meaning you can do operations like:
v1 <- c(1, 2, 3, 4) v2 <- c(5, 6, 7, 8) v2-v1
## [1] 4 4 4 4
instead of writing a for loop to subtract the individual elements
The packages inside the tidyverse, e.g dplyr, let you do data cleaning and manipulation operations easily when data is in tidy format.
Using these packages can help - write faster and more ‘readable’ code
%>% “pipe” operator for chainingfilter to subset a dataframegroup_by and then summarisefacet to create small multiples plotsleft_join to join datasetsOR
install.packages("sf")
install.packages("tidycensus")
install.packages("dplyr")
install.packages("ggplot2")
install.packages("tidyr")
install.packages("purrr")
install.packages("lwgeom")
library(dplyr) library(ggplot2) library(tidyr) library(sf) library(tidycensus) library(tigris) library(purrr)
Get an API Key from http://api.census.gov/data/key_signup.html
census_api_key("<YOUR API KEY>")
demo_variables <- # define the variables you want to analyze here
de_census_data <- get_acs(geography = "tract",
state = "DE",
variables = demo_variables,
geometry = TRUE,
cb = TRUE)
OR
Load de_census_data.RData
load("data/de_census_data.RData")
de_census_data
## Simple feature collection with 2616 features and 5 fields (with 12 geometries empty) ## geometry type: MULTIPOLYGON ## dimension: XY ## bbox: xmin: -75.78866 ymin: 38.45101 xmax: -75.04894 ymax: 39.83901 ## epsg (SRID): 4269 ## proj4string: +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs ## First 10 features: ## GEOID NAME ## 1 10001040100 Census Tract 401, Kent County, Delaware ## 2 10001040100 Census Tract 401, Kent County, Delaware ## 3 10001040100 Census Tract 401, Kent County, Delaware ## 4 10001040100 Census Tract 401, Kent County, Delaware ## 5 10001040100 Census Tract 401, Kent County, Delaware ## 6 10001040100 Census Tract 401, Kent County, Delaware ## 7 10001040100 Census Tract 401, Kent County, Delaware ## 8 10001040100 Census Tract 401, Kent County, Delaware ## 9 10001040100 Census Tract 401, Kent County, Delaware ## 10 10001040100 Census Tract 401, Kent County, Delaware ## variable estimate moe ## 1 white 6080 502 ## 2 black 501 100 ## 3 asian 58 60 ## 4 hispanic 265 198 ## 5 foreignborn 132 125 ## 6 high_school_diplomas 1808 273 ## 7 bachelor_degrees 268 122 ## 8 masters_degrees 181 97 ## 9 households_earning_over_200k 51 50 ## 10 median_income 63324 8985 ## geometry ## 1 MULTIPOLYGON (((-75.7601 39... ## 2 MULTIPOLYGON (((-75.7601 39... ## 3 MULTIPOLYGON (((-75.7601 39... ## 4 MULTIPOLYGON (((-75.7601 39... ## 5 MULTIPOLYGON (((-75.7601 39... ## 6 MULTIPOLYGON (((-75.7601 39... ## 7 MULTIPOLYGON (((-75.7601 39... ## 8 MULTIPOLYGON (((-75.7601 39... ## 9 MULTIPOLYGON (((-75.7601 39... ## 10 MULTIPOLYGON (((-75.7601 39...
We use the ggplot2 package for layering plot info. geom_sf is used to map the varied shapes (polygons, lines)
ggplot(de_census_data, aes(fill = estimate))
ggplot(de_census_data, aes(fill = estimate)) + geom_sf()
ggplot(de_census_data, aes(fill = estimate)) + geom_sf() + scale_fill_viridis_c() + theme_minimal()
ggplot(de_census_data, aes(fill = estimate)) + geom_sf() + scale_fill_viridis_c() + theme_minimal() + labs(title = "Estimates by Census Tract")
%>%de_census_data_clean <- de_census_data %>%
separate(col = NAME, into = c("Census_Tract", "County", "State"),
sep = ",") %>%
separate(col = Census_Tract, into = c("Census", "Tract", "Census_Tract_Number"),
sep = " ")
Let’s look at the above code step by step
de_census_data %>% # take the data, and then
separate(col = NAME, into = c("Census_Tract", "County", "State"),
sep = ",") # separate by ','
## Simple feature collection with 2616 features and 7 fields (with 12 geometries empty) ## geometry type: MULTIPOLYGON ## dimension: XY ## bbox: xmin: -75.78866 ymin: 38.45101 xmax: -75.04894 ymax: 39.83901 ## epsg (SRID): 4269 ## proj4string: +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs ## First 10 features: ## GEOID Census_Tract County State ## 1 10001040100 Census Tract 401 Kent County Delaware ## 2 10001040100 Census Tract 401 Kent County Delaware ## 3 10001040100 Census Tract 401 Kent County Delaware ## 4 10001040100 Census Tract 401 Kent County Delaware ## 5 10001040100 Census Tract 401 Kent County Delaware ## 6 10001040100 Census Tract 401 Kent County Delaware ## 7 10001040100 Census Tract 401 Kent County Delaware ## 8 10001040100 Census Tract 401 Kent County Delaware ## 9 10001040100 Census Tract 401 Kent County Delaware ## 10 10001040100 Census Tract 401 Kent County Delaware ## variable estimate moe ## 1 white 6080 502 ## 2 black 501 100 ## 3 asian 58 60 ## 4 hispanic 265 198 ## 5 foreignborn 132 125 ## 6 high_school_diplomas 1808 273 ## 7 bachelor_degrees 268 122 ## 8 masters_degrees 181 97 ## 9 households_earning_over_200k 51 50 ## 10 median_income 63324 8985 ## geometry ## 1 MULTIPOLYGON (((-75.7601 39... ## 2 MULTIPOLYGON (((-75.7601 39... ## 3 MULTIPOLYGON (((-75.7601 39... ## 4 MULTIPOLYGON (((-75.7601 39... ## 5 MULTIPOLYGON (((-75.7601 39... ## 6 MULTIPOLYGON (((-75.7601 39... ## 7 MULTIPOLYGON (((-75.7601 39... ## 8 MULTIPOLYGON (((-75.7601 39... ## 9 MULTIPOLYGON (((-75.7601 39... ## 10 MULTIPOLYGON (((-75.7601 39...
de_census_data %>% # take the data, and then
separate(col = NAME, into = c("Census_Tract", "County", "State"),
sep = ",") %>% # separate by ',' and then
separate(col = Census_Tract, into = c(NA, NA, "Census_Tract_Number"),
sep = " ") # separate out Number and then
## Simple feature collection with 2616 features and 7 fields (with 12 geometries empty) ## geometry type: MULTIPOLYGON ## dimension: XY ## bbox: xmin: -75.78866 ymin: 38.45101 xmax: -75.04894 ymax: 39.83901 ## epsg (SRID): 4269 ## proj4string: +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs ## First 10 features: ## GEOID Census_Tract_Number County State ## 1 10001040100 401 Kent County Delaware ## 2 10001040100 401 Kent County Delaware ## 3 10001040100 401 Kent County Delaware ## 4 10001040100 401 Kent County Delaware ## 5 10001040100 401 Kent County Delaware ## 6 10001040100 401 Kent County Delaware ## 7 10001040100 401 Kent County Delaware ## 8 10001040100 401 Kent County Delaware ## 9 10001040100 401 Kent County Delaware ## 10 10001040100 401 Kent County Delaware ## variable estimate moe ## 1 white 6080 502 ## 2 black 501 100 ## 3 asian 58 60 ## 4 hispanic 265 198 ## 5 foreignborn 132 125 ## 6 high_school_diplomas 1808 273 ## 7 bachelor_degrees 268 122 ## 8 masters_degrees 181 97 ## 9 households_earning_over_200k 51 50 ## 10 median_income 63324 8985 ## geometry ## 1 MULTIPOLYGON (((-75.7601 39... ## 2 MULTIPOLYGON (((-75.7601 39... ## 3 MULTIPOLYGON (((-75.7601 39... ## 4 MULTIPOLYGON (((-75.7601 39... ## 5 MULTIPOLYGON (((-75.7601 39... ## 6 MULTIPOLYGON (((-75.7601 39... ## 7 MULTIPOLYGON (((-75.7601 39... ## 8 MULTIPOLYGON (((-75.7601 39... ## 9 MULTIPOLYGON (((-75.7601 39... ## 10 MULTIPOLYGON (((-75.7601 39...
# this result is assigned to de_census_data_clean using the assignment operator '<-'
# Let's look at the number of foreignborn in each Tract
de_census_fb <- de_census_data_clean %>%
filter(variable %in% c("foreignborn"))
ggplot(de_census_fb, aes(fill = estimate)) +
geom_sf() +
scale_fill_viridis_c() +
coord_sf(crs = 26916, datum = NA) +
labs(title = "Foreign-Born Estimates by DE Census Tract",
caption = "Data: 2013-2017 5-year ACS",
fill = "ACS estimate")
ggplot(de_census_fb, aes(fill = estimate)) +
geom_sf() +
scale_fill_viridis_c() +
coord_sf(crs = 26916, datum = NA) +
labs(title = "Foreign-Born Estimates by DE Census Tract",
caption = "Data: 2013-2017 5-year ACS",
fill = "ACS estimate")
# Wilmington Tracts
wilm_census_data <- de_census_data_clean %>%
filter(Census_Tract_Number %in% c(2, 3, 4, 5, 6.01, 6.02, 9, 11, 12,
13, 14, 15, 16, 19.02, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30.02))
# Plot all our data
ggplot(wilm_census_data, aes(fill = estimate)) +
geom_sf() +
scale_fill_viridis_c() +
coord_sf(crs = 26916, datum = NA) +
labs(title = "Estimates by Census Tract",
subtitle = "Wilmington, DE",
caption = "Data: 2013-2017 5-year ACS
\nData acquired with the R tidycensus package.",
fill = "ACS estimate") +
facet_wrap(~variable)
## filter race
wilm_census_race <- wilm_census_data %>%
filter(variable %in% c("hispanic", "black", "asian", "white"))
ggplot(wilm_census_race, aes(fill = estimate)) +
geom_sf() +
scale_fill_viridis_c() +
coord_sf(crs = 26916, datum = NA) +
labs(title = "Population Estimates",
subtitle = "Wilmington, DE",
fill = "ACS estimate") +
facet_wrap(~variable)
‘Small multiples plots’ are useful to compare between variables. But we need to make sure we compare the right proportions so as to not let people take away a wrong insight.
Let’s do some data aggregation and data joins to find the percentages within each tract.
Highlight sections and run using cmd+ return to see the separate steps.
# get the total population by summing up the different race estimates wilm_tract_pop <- wilm_census_race %>% group_by(Census_Tract_Number) %>% summarise(Population_Estimate = sum(estimate)) st_geometry(wilm_tract_pop) <- NULL # remove geometry wilm_tract_percpop <- wilm_census_race %>% left_join(wilm_tract_pop, by = "Census_Tract_Number") %>% mutate(Percentage = estimate/Population_Estimate)
Note: tidycensus allows you to get the summary value through the API as well!
ggplot(wilm_tract_percpop, aes(fill = Percentage)) +
geom_sf() +
scale_fill_viridis_c() +
coord_sf(crs = 26916, datum = NA) +
labs(title = "Percentage of Population (Estimates) by Census Tract",
subtitle = "Wilmington, DE",
fill = "ACS estimate") +
facet_wrap(~variable)
You can create a Wilmington Education variable by filtering c("high_school_diplomas", "bachelor_degrees", "masters_degrees") variables and recreating the previous visualizations for these variables.
wilm_census_edu <- wilm_census_data %>%
filter(variable %in% c("high_school_diplomas", "bachelor_degrees", "masters_degrees"))
ggplot(wilm_census_edu, aes(fill = estimate)) +
geom_sf() +
scale_fill_viridis_c() +
coord_sf(crs = 26916, datum = NA) +
labs(title = "Education Estimates",
subtitle = "Wilmington, DE",
fill = "ACS estimate") +
facet_wrap(~variable)
# As a percentage of education data available (this isn't perfect)
# get the total population by summing up the different race estimates
wilm_tract_totedu <- wilm_census_edu %>%
group_by(Census_Tract_Number) %>%
summarise(Education_Estimate = sum(estimate))
st_geometry(wilm_tract_totedu) <- NULL # remove geometry
wilm_tract_percedu <- wilm_tract_totedu %>%
left_join(wilm_census_edu, by = "Census_Tract_Number") %>%
mutate(Percentage = estimate/Education_Estimate)
# Plot
ggplot(wilm_tract_percedu, aes(fill = Percentage)) +
geom_sf() +
scale_fill_viridis_c() +
coord_sf(crs = 26916, datum = NA) +
labs(title = "Percentage of Education Estimates by Census Tract",
subtitle = "Wilmington, DE",
fill = "ACS estimate") +
facet_wrap(~variable)
Choropleth maps have a tendency of being misunderstood due to the area covered by a color. We can plot dots in order to avoid the issue of misrepresentation of sparsely populated areas and give an idea of density.
Hold tight as this will have some heavy lifting with functions from dplyr and purrr!
wm_dots <- map(c("white", "black", "asian", "hispanic"), function(group) {
wilm_census_data %>%
filter(variable == group) %>%
st_sample(., size = .$estimate / 10, exact = FALSE) %>%
st_sf() %>%
mutate(group = group)
}) %>%
reduce(rbind) %>%
group_by(group) %>%
summarize()
## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar ## although coordinates are longitude/latitude, st_intersects assumes that they are planar
map Applys a function to each element of a vector, in our case the vector is the race values. i.e, for each race we subset the wilmington data, and create dots representing the population in each tract.
wilm_census_data %>%
filter(variable == group) %>%
st_sample(., size = .$estimate / 10, exact = FALSE) %>%
st_sf() %>%
mutate(group = group)
ggplot() +
geom_sf(data = wilm_census_data, color = "grey95", fill = "white") +
geom_sf(data = wm_dots, aes(color = group, fill = group),
size = 0.1, alpha = 0.5) +
theme_minimal()
Data being tidy allowed us to immediately use commands like:
Remember ACS are estimates so we should consider the MOE or Margin of Error variable.